package com.neu.commons.Utils;

import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

import static java.lang.Math.random;

public class EmailUtils {


    public String sendemail(String youxiang) {
        String b="";
        Email email=new HtmlEmail();
        email.setHostName("smtp.163.com");
        email.setAuthentication("15610618756","123456789.");
        email.setCharset("utf-8");
        try {
            email.setFrom("15610618756@163.com","我很好");
            email.addTo(youxiang);
            email.setSubject("验证码");
           int a= (int) (Math.random()*100+1);
           b=String.valueOf(a);
            System.out.println(b);
            email.setMsg(b);
           email.send();


        } catch (EmailException e) {
            e.printStackTrace();
        }


        return  b;
    }
}
